<template>
  <div class="box-list-container">
    <div class="box-query-form">
      <el-form :model="queryParam" label-width="auto" label-position="right" :gutter="24">
        <el-row>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="客户名称:">
              <el-input v-model="queryParam.clientName" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="编码:">
              <el-input v-model="queryParam.euid" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="域名:">
              <el-input v-model="queryParam.url" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24" class="table-search-btn">
            <el-button icon="el-icon-refresh" @click="searchReset">重置</el-button>
            <el-button type="primary" icon="el-icon-search" @click="searchQuery">查询</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="box-table">
      <div class="table-title">
        <div class="table-title-left">
          外部接口列表
        </div>
        <div>
          <el-button plain class="btnAdd" icon="el-icon-plus" @click="handleAdd('新增')">新增</el-button>
        </div>
      </div>
      <!-- 批量操作 -->
      <div v-if="selectedRowList.length" class="batchAction">
        <div class="batchAction-left">
          <el-dropdown>
            <el-button>
              批量操作 <i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>
                <div @click="batchDelete"><i class="el-icon-delete" />删除</div>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
        <div class="batchAction-right">
          已选择
          <span style="font-weight: 700">
            <el-link type="primary" :underline="false">{{ selectedRowList.length }}</el-link>
          </span>项
          <el-link type="primary" :underline="false" style="margin-left: 24px;" @click="onClearSelected">清空</el-link>
        </div>
      </div>
      <el-table ref="table" :data="dataSource" @selection-change="onSelectChange">
        <el-table-column type="selection" width="55" />
        <el-table-column fixed="left" prop="id" label="ID" width="60" />
        <el-table-column prop="clientName" label="客户名称" min-width="100" />
        <el-table-column prop="successCharacter" label="成功字符" min-width="100" />
        <el-table-column prop="url" label="域名" min-width="200" />
        <el-table-column fixed="right" label="操作" width="180">
          <template slot-scope="scope">
            <el-button type="text" @click="parameterSet(scope.row)">参数设置</el-button>
            <el-button type="text" @click="handleEdit('编辑', scope.row)">编辑</el-button>
            <el-popconfirm title="确定删除吗？" style="margin-left: 10px" @confirm="handleDelete(scope.row[guidFieldName])">
              <el-button slot="reference" type="text" style="color: red;">删除</el-button>
            </el-popconfirm>
          </template>
        </el-table-column>
      </el-table>
      <div class="box-paging">
        <Pagination
          v-show="ipagination.total > 0"
          layout="total, sizes, prev, pager, next"
          :total="ipagination.total"
          :page.sync="ipagination.pageNum"
          :limit.sync="ipagination.pageSize"
          @pagination="loadData"
        />
      </div>
    </div>
    <handleDrawer ref="modalForm" @ok="modalFormOk" />
    <parameterSet ref="parameterSet" @ok="modalFormOk" />
  </div>
</template>

<script>
import { listMixin } from '@/mixins/listMixin'
import Pagination from '@/components/Pagination'
import handleDrawer from './components/handleDrawer'
import parameterSet from './components/parameterSet'

export default {
  components: {
    Pagination,
    handleDrawer,
    parameterSet
  },
  mixins: [listMixin],
  data() {
    return {
      guidFieldName: 'id',
      ipagination: {
        pageNum: 1,
        pageSize: 100,
        total: 0
      },
      toggleSearchStatus: false,
      userInfo: this.$ls.get('USER_INFO') || {},
      url: {
        list: 'externalApi.aspx?action=GetList',
        delete: 'externalApi.aspx?action=Delete',
        deleteBatch: 'externalApi.aspx?action=DeleteBatch'
      }
    }
  },
  created() {},
  mounted() {},
  methods: {
    // 参数设置
    parameterSet(rowData) {
      this.$refs.parameterSet.show(rowData.id)
      this.$refs.parameterSet.title = '参数设置'
    }
  }
}
</script>

<style lang="scss" scoped>
</style>

